<template>
	<view>
		<u-popup :show="show" :round="10" mode="bottom" bgColor="#282828" closeable @close="show=false;">
			<view class="mainpadding flexleft">
				<view class="flexcolumn">
					<text class="bold titletext xiaolan">礼物</text>
					<view class=" margin_top2 lanline"></view>
				</view>
			</view>
			<view class="" style="padding: 0 0 40rpx 0;">
				<scroll-view scroll-y="true" style="height: 350rpx;">
					<view class="flexleft flex_wrap">
						<view class="sanshis flexcenter" style="margin-top: 15rpx;" v-for="item in lwList"
							:key="item.id" @click.stop="sendlwfs(item)">
							<view class="flexcolumn liwuhezi">
								<image :src="item.image_text" style="width: 120rpx;height: 120rpx;" mode="">
								</image>
								<text class="margin_top2 xiaobai textcenter bold">{{item.name}}</text>
								<text class="xiaohui smalltext margin_top1">{{item.jb_num}}金币</text>
							</view>
						</view>
					</view>
				</scroll-view>
				<view class="bottomjbcz mainpadding flexleft">
					<image src="@/static/image/system/jinbi.png" class="margin_right1"
						style="width: 30rpx;height: 30rpx;" mode="">
					</image>
					<text class="xiaobai sanshier bold margin_right1"
						style="line-height: 32rpx;">{{myJbNum || 0}}</text>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		name: "liwuth",
		props: ["send_user_id"],
		data() {
			return {
				show: false,
				lwList: [],
				myJbNum: ""
			};
		},
		created() {
			this.userinfofn()
			this.getlwinit()
		},
		methods: {
			userinfofn() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.myJbNum = res.data.jb_num
				})
			},
			sendlwfs(item) {
				httpRequest.request('/api/user/sendGift', 'GET', {
					gift_id: item.id,
					send_user_id: this.send_user_id
				}).then(res => {
					if (res.code == 1) {
						this.sendlinews(item.id)
						this.$emit("sendlw", item.image)
						this.myJbNum = Number(this.myJbNum) - Number(item.jb_num)
						this.show = false
					} else {
						httpRequest.toast(res.msg)
					}
				})
			},
			// 告诉对方我给对方发送礼物了 赠送礼物自定义
			sendlinews(id){
				httpRequest.request('/api/user/sendgiftdata', 'GET', {
					gift_id: id,
					user_id: this.send_user_id
				}).then(res => {
					
				})
			},
			getlwinit() { //礼物数据
				httpRequest.request('/api/user/giftIndex', 'GET', {}).then(res => {
					this.lwList = res.data
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.lanline{
		width: 40rpx;
		height: 5rpx;
		background-color: #2261ff;
	}
	.flexbetween {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-direction: row;
	}

	.flexleft {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		flex-direction: row;
	}

	.sanshis {
		width: 250rpx;
	}

	.margin_top2 {
		margin-top: 20rpx;
	}

	.flexcolumn {
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
<style scoped lang="scss">
	.liwuhezi {
		width: 210rpx;
		padding: 30rpx 0;
		font-size: 30rpx;
		color: #fff;
	}
</style>